﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZK.MyControl;

namespace ZK.Client
{
    public partial class FrmSplash : Form
    {
        public FrmSplash()
        {
            InitializeComponent();
        }


        CancellationTokenSource cts = new CancellationTokenSource();
        private void FrmSplash_Load(object sender, EventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {

                    for (int i = 2; i >= 0; i--)
                    {

                        if (cts.IsCancellationRequested)
                            break;
                        lblLeftSecond.LableShow(i + "S");
                        Thread.Sleep(1000);
                    }
                    FormClose();

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            });

        }

 
        public void FormClose()
        {
            Action action = () =>
            {
                this.Close();
            };


            if (this.InvokeRequired)
            {
                this.Invoke(action);
            }
            else
            {
                this.Close();
            }
        }

    

        private void lblLeftSecond_Click(object sender, EventArgs e)
        {
            cts.Cancel();
        }

        private void panel1_Resize(object sender, EventArgs e)
        {
            SetWindowRegion.SetWindowSadius(20,this);
        }
    }
}